<?xml version="1.0" encoding="utf-8" ?>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<jsp:include page="/commonPart/htmlHeader2.jsp">
	<jsp:param name="title" value="更改头像图片-${userInfo.name}的个人空间-CommonWorld" />
</jsp:include>
<body>
<div id = "CW_Screen" >
	<jsp:include page= "/commonPart/bodyHeader2.jsp" ></jsp:include>
	<div id = "CW_Content">
		<div id = "SpaceLeft">
			<div class = "AdminNav clearfix">
				<a href = "${userUrls.home}" class = "u" title = "返回我的空间首页">
					<img src = "${userInfo.headImage}" alt = "${userInfo.name}" class = "SmallPortrait" user = "${userInfo.id}" />	
				</a>
				<span class = "h">空间管理</span>
			</div>
			<div id = "AdminMenus" class = "Mod">
				<ul>
					<li class = "caption">
						<strong>个人信息管理</strong>
						<ol>
							<li><a href = "${userUrls.adminInbox}">站内留言</a></li>
							<li><a href = "${userUrls.adminProfile}">修改个人资料</a></li>
							<li><a href = "${userUrls.adminChqwd}">更改登录密码</a></li>
							<li><a href = "${userUrls.adminPortrait}">更改头像图片</a></li>
						</ol>
					</li>
				</ul>
				<ul>
					<li class = "caption">
						<strong>博客管理</strong>
						<ol>
							<li><a href = "${userUrls.adminNewBlog}">发表博客</a></li>
							<li><a href = "${userUrls.adminDrafts}">草稿箱(${draftInfos.count})</a></li>
							<li class = "active"><a href = "${userUrls.adminBlogCatalogs}">博客设置/分类管理</a></li>
						</ol>
					</li>
				</ul>
			</div>
		</div>
		<div class = "SpaceList" id = "AdminBody">
			<div class = "TopBar">
				<div class = "NavPath">
					<a href = "${userUrls.home}">空间</a>
					>>
					<a href = "${userUrls.blog}">博客</a>
					>>
					<a href = "${userUrls.adminBlogCatalogs}">博客设置/分类管理</a>
				</div>
			</div>
			<div class = "AdminHead">
				<div class = "RelativeLinks">
					<a class = "rndbutton" href = "${userUrls.blog}"><span>我的博客</span></a>
				</div>
				<h1>博客设置/分类管理</h1>
			</div>
			<div class = "AdminContent MainForm BlogCatalogManage">
				<form id = "CatalogForm" action = "/action/blog/addBlogCatalog?catalogId=${catalogId}" method="post">
					<h3>添加博客分类</h3>
					<div class = "error_msg" id = "error_msg" style = "display: none;"></div>
					<label>分类名称: </label>
					<input name = "name" tabindex = "1" id = "txt_link_name" type = "text" size = "15" value = ""></input>
					<label>排序值: </label>
					<input name = "sortOrder" type = "text" size = "3" value = "0" />
					<span class = "submit">
						<input tabindex = "3" class = "BUTTON SUBMIT" type = "submit" value = "添加  >>" />
					</span>
				</form>
				<form class = "BlogCatalogs">
					<h3>
						博客分类<span>(点击分类名编辑)</span>
					</h3>
					<table cellpadding="1" cellspacing="1">
						<tr>
							<th>序号</th>
							<th>分类名</th>
							<th>文章</th>
							<th>操作</th>
						</tr>
						<c:forEach items = "${blogCatalogs}" var = "catalog">
							<tr id = "catalog_${catalog.catalogId}">
								<td class = "idx">${catalog.sortOrder}</td>
								<td class = "name"><a title = "点击修改博客分类 " href = "?edit_catalog=${catalog.catalogId}">${catalog.name}</a></td>
								<td class = "num">${catalog.blogCount}</td>
								<td class = "opts">
									<a title = "点击修改博客分类" href = "?edit_catalog=${catalog.catalogId}">修改</a>
									<a href = "javascript:delete_catalog(${catalog.catalogId})">删除</a>
								</td>
							</tr>
						</c:forEach>
					</table>
				</form>
			</div>
			<script>
				$().ready(function() {
					$('#CatalogForm').ajaxForm({
						success: function(html) {
							if (html.length == 0)
								location.reload();
							else {
								$('#error_msg').hide();
								$('#error_msg').html(html);
								$('#error_msg').show();
							}
						}
					});
				});
				function delete_catalog(id) {
					if (!confirm('删除博客分类将会删除所有此分类文章，确定要删除吗？'))
						return;
					ajax_post('/action/blog/deleteBlogCatalog', 'catalogId=' + id, function(html) {
						if (html.length > 0)
							alert(html);
						else
							$('#catalog_' + id).remove();
					});
				}
			</script>
		</div>
	</div>
	<div class = "clear"></div>
	<div id = "footer"></div>
</div>
</body>
</html>